# -*- coding: utf-8 -*-
import re

import scrapy


class ZdmSpider(scrapy.Spider):
    name = 'zdm'
    allowed_domains = ['smzdm.com']
    start_urls = ['https://m.smzdm.com/youhui/']

    def parse(self, response):
        a_list = response.xpath("//ul/li[@class='card-group-list']/a/div/div")
        for a_temp in a_list:
            title = a_temp.xpath("./div[@class='card-title']/text()").extract_first()
            price01 = a_temp.xpath("./div[@class='card-price']/text()").extract_first()
            platform = a_temp.xpath(".div/div/span/span[@class='card-mall']/text()").extract_first()
            data_time = a_temp.xpath("./div/div/span/span[2]/text()").extract_first()
            if title is not None:
                price02 = re.findall(r"[（](.*?)[）]", price01)
                print('---------------', title, price02, platform, data_time)

